package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 业务层:Service注解表示将该类交由Spring框架管理
 */

@Service
public class UserService {
    //业务名称
    @Value("登录")
    private String name;
    /*
    Autowired:对象类型的属性值注入;
    required参数: true表示如果装配[注入]失败,则抛出异常;
                 false表示不管装配成功还是失败,都不会抛出异常,一般不使用;
     */
    //@Autowired(required = true)
    private UserDao userDao;

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    @Autowired(required = true)
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
}







